﻿#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.BillingDemo1.GeneralBusinessObjects;
using DynConDevCorp.OpenArch.SmartData.Core;
using DynConDevCorp.OpenArch.SmartData.Interfaces.Attributes;
using DynConDevCorp.OpenArch.SmartData.WinForms;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.BillingDemo1.SmartUIControls
{
    public partial class AddressControl : SmartEntityControl
    {
        #region Constructors

        public AddressControl()
        {
            InitializeComponent();
            EntityBindingManager.BoundEntityChanged += EntityBindingManager_BoundEntityChanged;
            Address = new SmartEntityLink<Address>();
            Address.LinkedEntityChanged += Address_LinkedEntityChanged;
        }

        void EntityBindingManager_BoundEntityChanged(object sender, EventArgs e)
        {
            Address entity = EntityBindingManager.BoundEntity as Address;
            Address.LinkedEntity = entity;
        }

        #endregion

        #region Public Instance Properties

        [AutoField]
        public SmartEntityLink<Address> Address { get; set; }

        #endregion

        #region Public Instance Methods

        public void Address_LinkedEntityChanged(object sender, EventArgs e)
        {
            bmcAddress.BoundEntity = Address.LinkedEntity;
        }

        #endregion
    }
}